package com.han.command;

import java.util.Map;
import java.util.Set;

/**
 * @ClassName OrderCommand
 * @Description 具体的命令类
 * @Author duoduo Han
 * @Date 2024/6/13 20:54
 */
public class OrderCommand implements Command{
    // 持有接收者对象：具体执行命令的对象
    private SeniorChef receiver;
    //订单对象：用于创建命令让厨师做饭
    private Order order;

    public OrderCommand(SeniorChef receiver, Order order) {
        this.receiver = receiver;
        this.order = order;
    }

    @Override
    public void execute(){
        System.out.println(order.getDiningTable()+"号桌的订单：");
        //拿到订单对象
        Map<String, Integer> foodDir = order.getFoodDir();
        //遍历map集合，让厨师做饭
        Set<String> keys = foodDir.keySet();
        for (String foodName : keys) {
            receiver.makeFood(foodName,foodDir.get(foodName));
        }
        System.out.println(order.getDiningTable()+"桌的订单已完成！");
    }


}
